package com.yswl.yeeduo.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.yswl.yeeduo.R;
import com.yswl.yeeduo.ui.bean.RankingDetailBean.RankingDetailListItemBean;
import com.yswl.yeeduo.ui.utils.ImageUtil;
import com.yswl.yeeduo.view.listview.BaseListViewAdapter;

public class RankingDeitalAdapter extends BaseListViewAdapter<RankingDetailListItemBean> {

	LayoutInflater mInflater;
	protected ImageLoader imageLoader;
	protected DisplayImageOptions mOptions;

	public RankingDeitalAdapter(Context context) {
		super(context);
		mInflater = LayoutInflater.from(context);
		mOptions = ImageUtil.getHeadDefaultOptions();
		imageLoader = ImageLoader.getInstance();

	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder viewHolder = null;
		if (convertView == null) {
			viewHolder = new ViewHolder();
			convertView = mInflater.inflate(R.layout.rankingdeital_list_item, null);
			viewHolder.numb = (TextView) convertView.findViewById(R.id.tv_ranking_numb);
			viewHolder.moneycount = (TextView) convertView.findViewById(R.id.tv_ranking_moneycount);
			viewHolder.name = (TextView) convertView.findViewById(R.id.tv_ranking_username);
			viewHolder.headIcon = (ImageView) convertView.findViewById(R.id.user_head_img);
			convertView.setTag(viewHolder);
		} else {
			viewHolder = (ViewHolder) convertView.getTag();
		}

		RankingDetailListItemBean bean = getItem(position);

		imageLoader.displayImage(bean.headIcon, viewHolder.headIcon, mOptions);
		viewHolder.name.setText(bean.name);
		viewHolder.numb.setText(bean.rank);
		viewHolder.moneycount.setText(bean.money);
		return convertView;
	}

	private static class ViewHolder {
		public TextView numb;
		public TextView name;
		public TextView moneycount;
		public ImageView headIcon;
	}

}
